//
//  TextFieldCell.m
//  QuXiang
//
//  Created by Duncan on 2020/6/30.
//  Copyright © 2020 NanHuaiZi. All rights reserved.
//

#import "TextFieldCell.h"

@implementation TextFieldCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.clipsToBounds = YES;
        [self.contentView addSubviews:[NSArray arrayWithObjects:self.leftLabel, self.rightTF, nil]];
        [self masonryLayout];
    }
    return self;
}

#pragma mark ------- Lazy Methods -------

- (void)masonryLayout {
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(kFragmemtFloat(15));
        make.centerY.equalTo(self.contentView);
        make.width.mas_equalTo(kFragmemtFloat(110));
    }];
    [self.rightTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftLabel.mas_right);
        make.right.equalTo(self.contentView.mas_right).offset(-kFragmemtFloat(15));
        make.top.bottom.equalTo(self.contentView);
    }];
}

- (UILabel *)leftLabel {
    if (!_leftLabel) {
        _leftLabel = [UILabel initWithTextColor:k_Color_TipColor fontSize:15];
    }
    return _leftLabel;
}

- (BaseTextField *)rightTF {
    if (!_rightTF) {
        _rightTF = [[BaseTextField alloc] init];
        _rightTF.font = kAdaptedFontSize(15);
        _rightTF.textAlignment = NSTextAlignmentRight;
        _rightTF.background = [UIImage kj_imageWithColor:[UIColor clearColor] size:CGSizeMake(1, 1)];
    }
    return _rightTF;
}


@end
